﻿using System.Web;

namespace CkSoftware.GroupMe.Sdk.TestWeb.Helpers
{
	public static class SessionConfiguration
	{
		public const string GroupMeBotApiKeyConfigKey = "GroupMeApiKey";

		public const string GroupMeGroupIdConfigKey = "GroupMeGroupId";

		public const string CallbackGroupId = "BotCallbackGroupId";

		public const string GroupMeClientAuthKey = "GroupMeClientAuthKey";

		public const string GroupMessagesStoreKeyFormat = "GroupMeMessages_Group_{0}";

		public const string DirectMessagesStoreKeyFormat = "GroupMeMessages_Direct_{0}";

		public const string GroupMeGroupKeyFormat = "GroupMeGroup_{0}";

		public static TValue GetConfigValue<TValue>(string key)
		{
			return HttpContext.Current.Session[key] is TValue ? (TValue) HttpContext.Current.Session[key] : default(TValue);
		}

		public static void SetConfigValue<TValue>(string key, TValue value)
		{
			HttpContext.Current.Session[key] = value;
		}

		public static bool IsConfigValueIsSet<TValue>(string key)
			where TValue : class
		{
			var value = GetConfigValue<TValue>(key);
			return value != null && !value.Equals(default(TValue));
		}
	}
}